package com.pearadmin.pro.modules.consult.rest;

import com.pearadmin.pro.modules.consult.domain.ConsultService;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.consult.domain.ConsultService;
import  com.pearadmin.pro.modules.consult.param.ConsultServiceRequest;
import  com.pearadmin.pro.modules.consult.service.ConsultServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 咨询服务Controller
 *
 * @author ChenJian
 * @date 2021-08-29
 */
@Api(tags = {"咨询服务"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"consultService/consultService")
public class ConsultServiceController extends BaseController
{
    @Resource
    private ConsultServiceService consultServiceService;

    /**
     * 查询咨询服务列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "咨询服务列表")
    @ApiOperation(value = "咨询服务列表")
    public Result<ConsultService> list(ConsultServiceRequest consultServiceRequest)
    {
        return success(consultServiceService.page(consultServiceRequest));
    }


    /**
     * 新增保存咨询服务
     * @param consultService 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增咨询服务")
    @ApiOperation(value = "新增咨询服务")
    public Result save(@RequestBody ConsultService consultService)
    {
        return auto(consultServiceService.save(consultService));
    }

    /**
     * 查询咨询服务详情
     *
     * @param id 咨询服务ID
     * @return 咨询服务
     */
    @GetMapping("/selectById")
    @Log(title = "查询咨询服务详情")
    @ApiOperation(value = "查询咨询服务详情")
    public Result<ConsultService> selectById(@RequestParam Long id)
    {
        return success(consultServiceService.selectConsultServiceById(id));
    }



    /**
     * 修改保存咨询服务
     * @param consultService 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改咨询服务")
    @ApiOperation(value = "修改咨询服务")
    public Result update(@RequestBody ConsultService consultService)
    {
        return auto(consultServiceService.updateById(consultService));
    }


    /**
     * 删除保存咨询服务
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除咨询服务")
    @ApiOperation(value = "删除咨询服务")
    public Result remove(@RequestParam Long id)
    {
        return auto(consultServiceService.removeById(id));
    }

    /**
    * 批量删除咨询服务
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除咨询服务")
    @ApiOperation(value = "批量删除咨询服务")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(consultServiceService.removeByIds(ids));
    }

}
